package com.upoint.sellorderservice.message;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author jsbintask@foxmail.com
 * @date 2018/12/6 15:36
 */
@Slf4j
@Component
public class MessageReceiver {
    @RabbitListener(bindings = {
        @QueueBinding(exchange = @Exchange("myExchange"), value = @Queue("myQueue"))
    })
    public void consume(String message) {
        log.info("received {}", message);
    }

    @RabbitListener(bindings = {
            @QueueBinding(exchange = @Exchange("myProductExchange"), value = @Queue("myProductQueue1"),
            key = "myProductKey1")
    })
    public void consumeProduct1(String message) {
        log.info("received 1111 {}", message);
    }


    @RabbitListener(bindings = {
            @QueueBinding(exchange = @Exchange("myProductExchange"), value = @Queue("myProductQueue2"),
            key = "myProductKey2")
    })
    public void consumeProduct2(String message) {
        log.info("received 22222 {}", message);
    }
}
